package com.bitongchong.test;

import java.math.BigDecimal;
import java.util.Scanner;

public class ExpressionToDouble {

	public static BigDecimal calculate(String str) {
		if (str == null) {
			return null;
		}
		if (str.length() == 1) {
			return new BigDecimal(str);
		}
		String sign = "";
		int index = 0;
		sign = "(";
		index = str.lastIndexOf(sign);
		if (index >= 0) {
			int rightIndex = str.indexOf(")", index);

			String left = str.substring(0, index);
			String right = "";
			if (rightIndex + 1 < str.length()) {
				right = str.substring(rightIndex + 1);
			}

			BigDecimal middle = calculate(str.substring(index + 1, rightIndex));
			return calculate(left + middle + right);
		}

		sign = "+";
		index = str.lastIndexOf(sign);
		if (index > 0) {
			BigDecimal left = calculate(str.substring(0, index));
			BigDecimal right = calculate(str.substring(index + 1));
			return left.add(right);
		}

		sign = "-";
		index = str.lastIndexOf(sign);
		if (index > 0) {
			BigDecimal left = calculate(str.substring(0, index));
			BigDecimal right = calculate(str.substring(index + 1));
			return left.subtract(right);
		}

		sign = "*";
		index = str.lastIndexOf(sign);
		if (index > 0) {
			BigDecimal left = calculate(str.substring(0, index));
			BigDecimal right = calculate(str.substring(index + 1));
			return left.multiply(right);
		}

		sign = "/";
		index = str.lastIndexOf(sign);
		if (index > 0) {
			BigDecimal left = calculate(str.substring(0, index));
			BigDecimal right = calculate(str.substring(index + 1));
			return left.divide(right,0,BigDecimal.ROUND_HALF_DOWN);
		}

		sign = "^";
		index = str.lastIndexOf(sign);
		if (index > 0) {
			BigDecimal left = calculate(str.substring(0, index));
			BigDecimal right = calculate(str.substring(index + 1));
			int i = right.intValue();
			return left.pow(i);
		}
		return new BigDecimal(str);
	}
	
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);
		String string = scanner.nextLine();

		try {
			System.out.println(calculate(string));
		} catch (Exception e) {
			System.out.println("ERROR");
		}
	}
}
